<style>
    .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
        margin-top: 0px;
        margin-bottom: 0px;
    }
</style>

<div class="container-fluid">
    <div class="row">
        <div class="panel panel-default" style="margin-bottom: 0px;">
            <div class="panel-heading" style="font-weight: bold">
                <span>在建工程房屋、构筑物基本信息</span>
            </div>
            <div class="panel-body">
                <div id="toolbar" style="margin-bottom: 5px;">
                    <div class="form-inline">
                        <button class="btn btn-info btn-sm" onclick="clickSearch()">
                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                            查询
                        </button>
                        <button class="btn btn-primary btn-sm" onclick="clickAdd()">新增</button>
                        <button class="btn btn-danger btn-sm" onclick="clickDeleteAll()">批量删除</button>
                        <button class="btn btn-success btn-sm" onclick="importExcel()">导入Excel</button>
                        <button class="btn btn-success btn-sm" onclick="exportExcel()">导出Excel</button>
                    </div>
                </div>
                <table id="list-table"></table>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        var h = $(window).height();
        $("#list-table").bootstrapTable({
            url:'getBuildingList',
            method:'post',
            sidePagination: 'server',
            pagination:true,
            pageSize:20,
            pageList:[10,20,50],
            pageNumber:1,
            height:h - 210,
            columns:[{
                checkbox:true
            },{
                title:'资产编号',
                field:'BUILDING_NO',
                sortable:true
            },{
                title:'所属在建工程编号',
                field:'CONS_NO',
                sortable:true
            },{
                title:'所属在建工程名称',
                field:'CONS_NAME',
                sortable:true
            },{
                title:'资产分类号',
                field:'ASSET_TYPE_ID',
                sortable:true
            },{
                title:'资产分类名称',
                field:'ASSET_TYPE',
                sortable:true
            },{
                title:'资产名称',
                field:'BUILDING_NAME',
                sortable:true
            },{
                title:'坐落位置',
                field:'LOCATION',
                sortable:true,
            },{
                title:'取得方式',
                field:'GETTYPE',
                sortable:true,
            },{
                title:'取得日期',
                field:'GET_DATE',
                sortable:true,
            },{
                title:'使用单位',
                field:'COLLEGE',
                sortable:true,
            },{
                title:'建筑面积',
                field:'BUILD_SIZE',
                sortable:true,
            },{
                title:'价值',
                field:'BUILDING_FEE',
                sortable:true,
            },{
                title:'状态',
                field:'STATUS',
                sortable:true,
            },{
                title:'操作',
                field:'BUILDING_NO',
                halign:'center',
                align:'center',
                formatter:function (value,rowData,index) {
                    var html1 = "<button class='btn btn-xs btn-default' BUILDING_NO='" + value + "' onclick='clickDetail(this)' style='margin: 2px;'>查看</button>";
                    return html1;
                }
            }],
            queryParams:function (params) {
                return params;
            },
            responseHandler:function (res) {
                console.log(res)
                return res;
            }
        });
    });


    function refreshTable() {
        $("#list-table").bootstrapTable('refresh');
    }

    function clickDetail(obj) {
        var buildingNo = $(obj).attr('BUILDING_NO');
        var h = $(window).height()*0.9;
        var w = $(window).width()*0.9;
        layer.open({
            title:'查看房屋、构筑物',
            area:[w + 'px', h + 'px'],
            type:2,
            content:"{:url('editPage')}?buildingNo=" + buildingNo
        });
    }


    function clickDeleteAll() {
        layer.confirm('确认删除选中的设备吗？',{icon:3});
    }

    function clickAdd() {
        var h = $(window).height()*0.9;
        var w = $(window).width()*0.9;
        layer.open({
            title:'新增房屋、构筑物',
            area:[w + 'px', h + 'px'],
            type:2,
            content:"{:url('addPage')}"
        });
    }

    function clickSearch() {
        var h = $(window).height()*0.8;
        var w = $(window).width()*0.3;
        if(w > 1200){
            w = 1200;
        }
        layer.open({
            title:'查询--请输入查询条件',
            area:[w + 'px', h + 'px'],
            type:2,
            content:"{:url('searchPage')}"
        });
    }

    function exportExcel() {
        var h = $(window).height()*0.8;
        var w = $(window).width()*0.8;
        if(w > 1200){
            w = 1200;
        }
        layer.open({
            title:'导出',
            area:[w + 'px', h + 'px'],
            type:2,
            content:"{:url('exportExcelPage')}"
        });
    }

    function importExcel() {
        var h = $(window).height()*0.8;
        var w = $(window).width()*0.8;
        if(w > 1200){
            w = 1200;
        }
        layer.open({
            title:'导入',
            area:[w + 'px', h + 'px'],
            type:2,
            content:"{:url('importPage')}",
            end:function () {
                refreshTable();
            }
        });
    }

</script>